<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/static/jquery-1.11.3.js"></script>

    <script>
        $(function () {
            $('#username').blur(function () {
                var username = $(this).val();

                var paramString = 'username=' + username;
                $.get('/checkUsername', paramString, function (data) {
                    $('#result').html(data.msg).css('color', data.success ? 'green' : 'red');
                })
            });
        });
    </script>

</head>
<body>

<span id="result"></span><br>
用户名：<input type="text" name="username" id="username">

</body>
</html>